home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 026-050 / scopedisk32 / btree / bplus.h < prev    next >
Text File  |  1995-03-18  |  3KB  |  71 lines

  1.  
  2. /*  bplus.h - data structures and constants  */
  3.  
  4.  
  5. #define IX_OK       1
  6. #define IX_FAIL     0
  7. #define EOIX       (-2)
  8. #define MAXKEY      100
  9. #define NUM_BUFS    8
  10. #define MAX_LEVELS  8
  11. #define IXB_SIZE    1024
  12. #define IXB_SPACE  (IXB_SIZE - sizeof(int) - sizeof(long) * 2)
  13.  
  14. typedef long RECPOS;
  15.  
  16. typedef struct                    /*  entry structure in index        */
  17.   {  RECPOS   idxptr;             /*  points to lower index level     */
  18.      RECPOS   recptr;             /*  points to data record           */
  19.      char     key[MAXKEY];        /*  start of record key             */
  20.   }  ENTRY;
  21.  
  22. typedef struct                    /*  index record format             */
  23.   {  RECPOS   brec;               /*  position in index file          */
  24.                                   /*  or location of next free block  */
  25.      int      bend;               /*  first unused block location     */
  26.      RECPOS   p0;                 /*  points to next level            */
  27.      char     entries[IXB_SPACE]; /*  here are the key entries        */
  28.   }  BLOCK;
  29.  
  30. typedef struct                    /*  disk file info                  */
  31.   {  RECPOS   ff;                 /*  location of first free block    */
  32.      int      nl;                 /*  number of index levels          */
  33.   }  IX_DISK;
  34.  
  35. typedef struct                    /*  memory buffer pool of indx blks */
  36.   {  int      dirty;              /*  true if changed                 */
  37.      int      handle;             /*  index file handle               */
  38.      int      count;              /*  number of times referenced      */
  39.      BLOCK    mb;
  40.   }  MEMBLOCK;
  41.  
  42. typedef struct
  43.   {  MEMBLOCK     cache [ NUM_BUFS ];
  44.   }  IX_BUFFER;
  45.  
  46. typedef struct                    /*  in-memory index descriptor      */
  47.   {  int      ixfile;
  48.      int      level;              /*  level in btree                  */
  49.      int      duplicate;          /*  no duplicate keys if 0          */
  50.      struct
  51.        {  RECPOS    cblock;       /*  position in index file          */
  52.           int       coffset;      /*  current offset within block     */
  53.        }  pos [ MAX_LEVELS ];
  54.      BLOCK    root;               /*  root index record               */
  55.      IX_DISK  dx;
  56.   }  IX_DESC;
  57.  
  58. int cdecl open_index(char *,IX_DESC *, int);
  59. int cdecl close_index(IX_DESC *);
  60. int cdecl make_index(char *,IX_DESC *, int);
  61. int cdecl first_key(IX_DESC *);
  62. int cdecl last_key(IX_DESC *);
  63. int cdecl next_key(ENTRY *, IX_DESC *);
  64. int cdecl prev_key(ENTRY *, IX_DESC *);
  65. int cdecl find_key(ENTRY *, IX_DESC *);
  66. int cdecl add_key(ENTRY *, IX_DESC *);
  67. int cdecl locate_key(ENTRY *, IX_DESC *);
  68. int cdecl delete_key(ENTRY *, IX_DESC *);
  69. int cdecl find_exact(ENTRY *, IX_DESC *);
  70.  
  71.